package org.go.scheduler.database;

import java.io.IOException;
import java.sql.Connection;
import java.sql.SQLException;

import org.go.scheduler.ScheduleBuilder;
import org.go.trigger.CronScheduleBuilder;
import org.go.trigger.Trigger;
import org.go.trigger.TriggerKey;
import org.go.work.Work;

/**
 * An interface which provides an implementation for storing a particular
 * type of <code>Trigger</code>'s extended properties.
 *  
 * @author jhouse
 */
public interface TriggerPersistenceDelegate {

	public class TriggerPropertyBundle {

		private ScheduleBuilder sb;
		private String[] statePropertyNames;
		private Object[] statePropertyValues;

		public TriggerPropertyBundle(CronScheduleBuilder cb, Object statePropertyNames2, Object statePropertyValues2) {
			// TODO Auto-generated constructor stub
		}

		public TriggerPropertyBundle(ScheduleBuilder sb, String[] statePropertyNames, Object[] statePropertyValues) {
			this.sb = sb;
			this.statePropertyNames = statePropertyNames;
			this.statePropertyValues = statePropertyValues;
		}

		public TriggerPropertyBundle(SimpleScheduleBuilder sb2, String[] statePropertyNames2, Object[] statePropertyValues2) {
			// TODO Auto-generated constructor stub
		}

		public ScheduleBuilder getScheduleBuilder() {
			return sb;
		}

		public String[] getStatePropertyNames() {
			return statePropertyNames;
		}

		public Object[] getStatePropertyValues() {
			return statePropertyValues;
		}
	}

	boolean canHandleTriggerType(Trigger trigger);

	int deleteExtendedTriggerProperties(Connection conn, TriggerKey triggerKey) throws SQLException;

	String getHandledTriggerTypeDiscriminator();

	void initialize(String tablePrefix, String schedulerName);

	int insertExtendedTriggerProperties(Connection conn, Trigger trigger, String state, Work jobDetail) throws SQLException, IOException;

	TriggerPropertyBundle loadExtendedTriggerProperties(Connection conn, TriggerKey triggerKey) throws SQLException;

	int updateExtendedTriggerProperties(Connection conn, Trigger trigger, String state, Work jobDetail) throws SQLException, IOException;
}
